package com.silverhaze.web.job;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import java.util.*;

/**
 * User: Babanin
 * Date: 16.01.12
 * Time: 20:53
 */
public class JobLauncherServlet extends HttpServlet {

    private static final long MLS_IN_MIN = 1000 * 60;
    private static final List<Job> jobs = Arrays.<Job>asList(new WoTStatisticsJob());

    @Override
    public void init() throws ServletException {
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                for (Job job : jobs) {
                    job.execute();
                }
            }
        }, 0, 60 * MLS_IN_MIN);
        
    }

    public static void add(Job job) {
        jobs.add(job);
    }
}
